#ifndef __input_listener_h__
#define __input_listener_h__

#include <OgreWindowEventUtilities.h>
#include <OgreFrameListener.h>
#include <OIS/OISKeyboard.h>
#include <OIS/OISMouse.h>
#include <fstream>

class InputListener : public Ogre::FrameListener, public OIS::KeyListener, public OIS::MouseListener, public Ogre::WindowEventListener{
	public:
		InputListener(Ogre::RenderWindow* win, Ogre::Camera* cam, Ogre::SceneManager *sceneMgr);

		bool frameStarted(const Ogre::FrameEvent &evt);
		bool frameEnded(const Ogre::FrameEvent &evt);

		bool mouseMoved(const OIS::MouseEvent &arg);
		bool mousePressed( const OIS::MouseEvent &arg, OIS::MouseButtonID id);
		bool mouseReleased( const OIS::MouseEvent &arg, OIS::MouseButtonID id);

		bool keyPressed(const OIS::KeyEvent &e);
		bool keyReleased(const OIS::KeyEvent &e);

		void toggleGuiLayer();

		OIS::Mouse* getMouse(){
      return mMouse;
    }
    
		OIS::Keyboard* getKeyboard(){
      return mKeyboard;
    }
    
    bool isGuiVisible(){
      return gui_layer_visible_;
    }
    
	protected:
    bool mContinue;
		bool gui_layer_visible_;
		OIS::InputManager *mInputManager;
		OIS::Mouse *mMouse;
		OIS::Keyboard *mKeyboard;
    Ogre::SceneManager *scene_manager_;
		void windowResized(Ogre::RenderWindow* rw);

		// Key repeat hax
		void keyRepeat(float elapsed);

		OIS::KeyCode mKey;
		unsigned int mChar;
		int mRepeats;
		float mElapsed;
		float mTimerElapsed;
};

#endif